-
Notifications
You must be signed in to change notification settings - Fork 683
feat: replace legacyInstamine option with instamine=eager|strict
#2013
Conversation
// ``` | ||
// If we don't have this delay here the messages will be sent before | ||
// the call has a chance to listen to the event. | ||
setImmediate(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out this was broken in greedy
mode!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is broken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The delay wasn't working. Our existing tests caught it when I switched the default.
await provider.send("eth_sendTransaction", ...);
await provider.once("message"); // <- this wasn't work, but it should.
// first mine operation to be fully complete. | ||
await emitBlockProm; | ||
} | ||
this.emit("block", finalizedBlockData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to wait because evm_mine
and miner_start
wait on their own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you feel it necessary to explain this in the review it likely belongs as a comment in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It explains why the old code was removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually having to revisit this because I noticed if someone sends stops the miner via miner_stop, send enough transactions to fill two blocks, then calls miner_start
, all pending transactions aren't mined before miner_start
returns... which is what we want.
I think evm_mine
suffers from a similar issue, but I haven't yet figured out what yet.
These issues might be rare enough that I can wait until after v7 stable to fix them, as it might take a bit of refactoring to get the timings correct.
const [finalLaterTxsReceipts, finalLaterTxsTransactions] = | ||
await Promise.all([ | ||
finalLaterTxsReceiptsProm, | ||
finalLaterTxsTransactionsProm | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(prettier change)
const { status, blockNumber } = await provider.send( | ||
"eth_getTransactionReceipt", | ||
[txHash] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(prettier change)
@@ -75,8 +75,7 @@ describe("api", () => { | |||
extraData: "0x", | |||
gasLimit: gasLimit, | |||
gasUsed: "0x0", | |||
hash: | |||
"0xe2c5d64b9e17e25abc0589c378b77adecf06668dd3c073ab9c53dec51baf2048", | |||
hash: "0xe2c5d64b9e17e25abc0589c378b77adecf06668dd3c073ab9c53dec51baf2048", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(prettier change)
const result = await strictInstamineProvider.send( | ||
"eth_getTransactionReceipt", | ||
[hash] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(prettier change)
const { gas, structLogs, returnValue, storage } = | ||
await this.#traceTransaction( | ||
newBlock.transactions[transaction.index.toNumber()], | ||
trie, | ||
newBlock, | ||
options | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(prettier change)
blocks.earliest = blocks.latest = | ||
await this.#blockBeingSavedPromise.then(({ block }) => block); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(prettier change)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left comments as questions mostly. Not a fan of greedy
and strict
.
// first mine operation to be fully complete. | ||
await emitBlockProm; | ||
} | ||
this.emit("block", finalizedBlockData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you feel it necessary to explain this in the review it likely belongs as a comment in the code.
instamine=greedy|strict
instamine=greedy|strict
instamine=eager|strict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more change request I couldn't make in the code - can we rename greedyInstamining.test.ts
since we're not calling it that anymore?
src/chains/ethereum/ethereum/tests/api/eth/getTransactionReceipt.test.ts
Outdated
Show resolved
Hide resolved
options.logging = options.logging || { logger: { log: () => {} } }; | ||
|
||
// set `asyncRequestProcessing` to `true` by default | ||
let doAsync = options.chain.asyncRequestProcessing; | ||
doAsync = options.chain.asyncRequestProcessing = | ||
doAsync != null ? doAsync : true; | ||
|
||
// don't write to stdout in tests | ||
if (!options.logging.logger) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we removing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't appear to actually do anything in our tests (I replaced it with throw new Error...
and all tests still passed)
* the transaction's hash is returned to the caller. If `legacyInstamine` is | ||
* `true`, `blockTime` must be `0` (default). | ||
* Set the instamine mode to either "eager" (default) or "strict". | ||
* * In "eager" mode a transaction will be included in a block before the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* * In "eager" mode a transaction will be included in a block before the | |
* * In "eager" mode a transaction will be included in a block before |
* | ||
* @defaultValue false | ||
* @deprecated Will be removed in v4 | ||
* @defaultValue eager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @defaultValue eager | |
* @defaultValue "eager" |
legacyName: "legacyInstamine", | ||
cliType: "boolean" | ||
cliDescription: `Set the instamine mode to either "eager" (default) or "strict". | ||
* In "eager" mode a transaction will be included in a block before the its hash is returned to the caller. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* In "eager" mode a transaction will be included in a block before the its hash is returned to the caller. | |
* In "eager" mode a transaction will be included in a block before its hash is returned to the caller. |
…pt.test.ts Co-authored-by: Micaiah Reid <[email protected]>
No description provided.